package tyk.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import tyk.common.MyExceptionEnum;
import tyk.common.Result;

/*
* 测试全局异常拦截器和自定义异常
* */
@RestController
public class TestExceptionController {

    @GetMapping("/exception")
    @ResponseBody
    public Result testException(String error){

        if ("ok".equals(error)) return Result.success(null);

        if ("err".equals(error)) return Result.error(MyExceptionEnum.CONTENT_NOT_EXIST.getMsg());

        if ("0".equals(error)) {
            int i = 1/0;
        }

        return Result.success(null);
    }
}
